package com.hello.sky.controller.admin;

import com.hello.sky.mapper.OrderDetailMapper;
import com.hello.sky.model.dto.DataOverViewQueryDTO;
import com.hello.sky.model.vo.OrderReportVO;
import com.hello.sky.model.vo.SalesTop10ReportVO;
import com.hello.sky.model.vo.TurnoverReportVO;
import com.hello.sky.model.vo.UserReportVO;
import com.hello.sky.result.Result;
import com.hello.sky.service.OrderDetailService;
import com.hello.sky.service.ReportService;
import com.hello.sky.service.UserService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.BufferedOutputStream;

@RestController
@RequestMapping("/admin/report")
public class ReportController {

    @Autowired
    private ReportService reportService;
    @Autowired
    private OrderDetailService orderDetailService;
    @Autowired
    private UserService userService;

    @GetMapping("/turnoverStatistics")
    public Result<TurnoverReportVO> turnoverStatistics(DataOverViewQueryDTO dto){
        TurnoverReportVO vo = reportService.turnoverStatistics(dto);
        return Result.success(vo);
    }

    @GetMapping("/ordersStatistics")
    public Result<OrderReportVO> ordersStatistics(DataOverViewQueryDTO dto){
        OrderReportVO vo = reportService.ordersStatistics(dto);
        return Result.success(vo);
    }

    @GetMapping("/userStatistics")
    public Result<UserReportVO> userStatistics(DataOverViewQueryDTO dto){
        UserReportVO vo = reportService.userStatistics(dto);
        return Result.success(vo);
    }

    @GetMapping("/top10")
    public Result<SalesTop10ReportVO> topTen(DataOverViewQueryDTO dto){
        SalesTop10ReportVO vo = reportService.topTen(dto);
        return Result.success(vo);
    }

    @GetMapping("/export")
    public void export(HttpServletResponse response){
        reportService.export(response);
    }
}
